package com.chauncy.DMS.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;

import com.chauncy.DMS.dao.ManagerDaoImplement;

public class RCHealthInfoServlet extends HttpServlet {


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		ManagerDaoImplement daoImplement = new ManagerDaoImplement();
		String sql = "SELECT sum(health_info_table.The_Value) AS `data`," +
				" health_info_table.Buildings_number AS name " +
				" FROM health_info_table " +
				" WHERE DATE_SUB(CURDATE(),INTERVAL 1 WEEK) <= health_info_table.Att_time " +
				" AND health_info_table.health_type = '日常卫生' " +
				" GROUP BY health_info_table.Buildings_number";
		List<Map<String, Object>> rcCountList =  daoImplement.query(sql);
		if(rcCountList != null && rcCountList.size() > 0){
			JSONArray array = JSONArray.fromObject(rcCountList);
			System.out.println(array);
			response.getWriter().print(array);
		}
		
	}

}
